package com.qfedu.web.servlet;

import com.alibaba.fastjson.JSON;
import com.qfedu.pojo.GoodsType;
import com.qfedu.service.GoodsTypeService;
import com.qfedu.service.impl.GoodsTypeServiceImpl;
import com.qfedu.web.common.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 创建者: QF-SUN
 * 创建时间: 2023/4/4 9:26
 * 描述:
 */
@WebServlet("/goodstypeservlet")
public class GoodsTypeServlet extends BaseServlet {

    GoodsTypeService goodsTypeService = new GoodsTypeServiceImpl();

    protected String goodstypelist(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //查询一级分类列表
        List<GoodsType> goodsTypeList =  goodsTypeService.getGoodsTypeLevel1();
        //转换为json字符串
        String json = JSON.toJSONString(goodsTypeList);

        return json;
    }
}
